package com.zretc.controller;

import com.zretc.entity.Product;
import com.zretc.entity.Type;
import com.zretc.service.ProductShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/ProductShowController")
public class ProductShowController {
    @Autowired
    private ProductShowService productShowService;

    /**
     * 根据店铺名查询商品
     *
     * @param shellName 店铺名称
     * @return
     */
    @RequestMapping("/getProductListByShellName")
    @ResponseBody
    List<Product> getProductListByShellName(String shellName) {
        List<Product> productList = productShowService.getProductListByShellName(shellName);

        return productList;
    }

    /**
     * 查詢所有的商品
     *
     * @return
     */
    @RequestMapping("/getAllProductList")
    List<Product> getAllProductList() {
        List<Product> productList = productShowService.getAllProduct();
        return productList;
    }

    /**
     * 一級分類
     *
     * @return
     */
    @RequestMapping("/getAllType")
    List<Type> getAllType() {
        List<Type> typeList = productShowService.getAlltype();
        return typeList;
    }


    /**
     * 查询二级分类
     *
     * @param typeFatherId 父类编号
     * @return
     */
    @RequestMapping("/getProductByParentIdList")
    @ResponseBody
    List<Product> getProductByParentIdList(String typeFatherId) {
        List<Product> productList = productShowService.getProductByParentId(typeFatherId);
        return productList;
    }

}
